package com.jingfu.configuration.shiro;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

import javax.annotation.PostConstruct;

/**
 * @author jingfuu@163.com
 * @version v1.0
 * @date 2022/1/14 下午2:29
 **/
@Configuration
public class MyConfiguration {
    public MyConfiguration() {
        int hashCode = this.hashCode();
        System.out.println("MyConfiguration 初始化"+"bean："+hashCode);
    }

    @Value("${jdbc.url}")
    private String value1;

    @Value("${shiro.loginUrl}")
    private String value2;

    @Value("#{ @environment['shiro.loginUrl'] ?: '/login.jsp' }")
    protected String loginUrl;
    @Value("#{ @environment['shiro.successUrl'] ?: '/' }")
    protected String successUrl;

    @Autowired
    private Environment environment;

    @PostConstruct
    public void init() {
        System.out.println("my configuration 初始化完成");
        String property = environment.getProperty("shiro.loginUrl");
        String property2 = environment.getProperty("jdbc.url");
    }
}
